package com.caleble.sample.dao.ibatis;

import com.caleble.sample.domain.Sample;
import com.caleble.sample.domain.SampleExample;
import com.caleble.sample.domain.SampleWithBLOBs;
import com.ibatis.sqlmap.client.SqlMapClient;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Scope("prototype")
@Transactional
public class SampleDAOImpl extends SqlMapClientDaoSupport implements SampleDAO {

	@Autowired
	public void setSuperSqlMapClient(SqlMapClient sqlMapClient) { // 自动注入SqlMapClient
		super.setSqlMapClient(sqlMapClient);
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public SampleDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public void insert(SampleWithBLOBs record) {
		getSqlMapClientTemplate().insert("CH_SAMPLE.abatorgenerated_insert", record);
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int updateByPrimaryKey(Sample record) {
		int rows = getSqlMapClientTemplate().update("CH_SAMPLE.abatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int updateByPrimaryKey(SampleWithBLOBs record) {
		int rows = getSqlMapClientTemplate().update("CH_SAMPLE.abatorgenerated_updateByPrimaryKeyWithBLOBs", record);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int updateByPrimaryKeySelective(SampleWithBLOBs record) {
		int rows = getSqlMapClientTemplate().update("CH_SAMPLE.abatorgenerated_updateByPrimaryKeySelective", record);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	@SuppressWarnings("unchecked")
	public List<Sample> selectByExampleWithoutBLOBs(SampleExample example) {
		List<Sample> list = (List<Sample>) getSqlMapClientTemplate().queryForList("CH_SAMPLE.abatorgenerated_selectByExample", example);
		return list;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	@SuppressWarnings("unchecked")
	public List<SampleWithBLOBs> selectByExampleWithBLOBs(SampleExample example) {
		List<SampleWithBLOBs> list = (List<SampleWithBLOBs>) getSqlMapClientTemplate().queryForList("CH_SAMPLE.abatorgenerated_selectByExampleWithBLOBs",
				example);
		return list;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public SampleWithBLOBs selectByPrimaryKey(BigDecimal id) {
		Sample key = new Sample();
		key.setId(id);
		SampleWithBLOBs record = (SampleWithBLOBs) getSqlMapClientTemplate().queryForObject("CH_SAMPLE.abatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int deleteByExample(SampleExample example) {
		int rows = getSqlMapClientTemplate().delete("CH_SAMPLE.abatorgenerated_deleteByExample", example);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int deleteByPrimaryKey(BigDecimal id) {
		Sample key = new Sample();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete("CH_SAMPLE.abatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int countByExample(SampleExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("CH_SAMPLE.abatorgenerated_countByExample", example);
		return count;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int updateByExampleSelective(SampleWithBLOBs record, SampleExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update("CH_SAMPLE.abatorgenerated_updateByExampleSelective", parms);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int updateByExample(SampleWithBLOBs record, SampleExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update("CH_SAMPLE.abatorgenerated_updateByExampleWithBLOBs", parms);
		return rows;
	}

	/**
	 * This method was generated by Abator for iBATIS. This method corresponds
	 * to the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	public int updateByExample(Sample record, SampleExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update("CH_SAMPLE.abatorgenerated_updateByExample", parms);
		return rows;
	}

	/**
	 * This class was generated by Abator for iBATIS. This class corresponds to
	 * the database table CH.SAMPLE
	 * 
	 * @abatorgenerated Mon Dec 22 10:02:25 CST 2008
	 */
	private static class UpdateByExampleParms extends SampleExample {
		private Object record;

		public UpdateByExampleParms(Object record, SampleExample example) {
			super(example);
			this.record = record;
		}

		public Object getRecord() {
			return record;
		}
	}

}